ALMaSS  1.0
The Animal, Landscape and Man Simulation System
GooseHunter Class Reference

The class for goose hunters encompsassing all their specific behaviours. More...

#include <Hunters_all.h>

Inheritance diagram for GooseHunter:
Hunter TAnimal TALMaSSObject

Public Member Functions

 GooseHunter (struct_Hunter *p_data, Hunter_Population_Manager *p_PPM)
 GooseHunter constructor. More...
 
virtual ~GooseHunter ()
 GooseHunter destructor. More...
 
virtual void Step ()
 GooseHunter Step code. More...
 
void OnShotABird (int a_birdtype, int a_poly)
 Message received when a goose is successully shot. More...
 
virtual void SaveMyData (ofstream *a_ofile)
 Each hunter needs to save different kinds of data, so we use a polymorphic method for this. More...
 
virtual void ResetBag ()
 Sets the annual hunting bag to zero. More...
 
bool IsLeader ()
 Returns the leader flag. More...
 
- Public Member Functions inherited from Hunter
 Hunter (struct_Hunter *p_data, Hunter_Population_Manager *p_PPM)
 The constructor for the Hunter class. More...
 
virtual ~Hunter ()
 The destructor for the Hunter class. More...
 
int GetHuntingDays ()
 Gets the annual hunting attempts count. More...
 
int GetBag ()
 Gets the annual hunting bag. More...
 
int GetShots ()
 Gets the number of shots this season to-date. More...
 
void ResetHuntingOpportunities ()
 Sets the annual hunting attempts count to zero. More...
 
int GetClock ()
 Supplies the clock time. More...
 
void ResetClock ()
 Sets the clock back to zero. More...
 
void ResetSeasonData ()
 Sets the bag and hunting counters to zero. More...
 
bool IsOutHunting ()
 A debug function, but may be useful in other contexts. Returns true of currently out hunting. More...
 
void OnMorning ()
 Optimism in the morning, perhaps we should hunt? More...
 
int GetRef ()
 Provide our ref name. More...
 
APoint GetHome ()
 Provide our home coords. More...
 
int GetHuntField ()
 Get the polygon reference number to our current hunting field (which is at a hunting location) More...
 
APoint GetHuntLoc (unsigned a_ref)
 Provide our hunting location coords. More...
 
FarmGetFarmerRef (unsigned a_ref)
 Provide our ref name. More...
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void BeginStep (void)
 BeingStep behaviour - must be implemented in descendent classes. More...
 
virtual void EndStep (void)
 EndStep behaviour - must be implemented in descendent classes. More...
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
virtual bool OnFarmEvent (FarmToDo)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Protected Member Functions

virtual void Init ()
 Initiation of a specific goose hunter here. More...
 
virtual bool InSeason (int day)
 Is it goose hunting season? - MUST be overridden in descendent class. More...
 
virtual bool IsSeasonEnd (int day)
 Is it the end of the goose hunting season? - MUST be overridden in descendent class. More...
 
virtual int GetSeasonLengthLeft (int day)
 Returns the length of the hunting season in days - MUST be overridden in descendent class. More...
 
TypeOfHunterState st_OutHunting (void)
 The basic hunting behaviour. More...
 
virtual TypeOfHunterState st_ShouldGoHunting (void)
 Behavior involved in deciding whether to go hunting. More...
 
bool FindHuntingLocation (void)
 Locate the hunt for today. More...
 
virtual int CheckForGame (void)
 If the hunter checks for game at their hunting locations then this is done here. Must be overridden. More...
 
virtual void OnShoot ()
 On shoot message handler. More...
 
virtual void OnGoHome ()
 On gohome message handler. More...
 
- Protected Member Functions inherited from Hunter
TypeOfHunterState st_OutHunting (void)
 The basic hunting behaviour. More...
 
TypeOfHunterState st_Resting (void)
 Finished hunting and waiting for the next opportunity. More...
 
virtual void Init (struct_Hunter *p_data)
 Initiation of a basic hunter here. More...
 
bool IsTodayAPreferredHuntDay (int a_today)
 Checks for the hunting day preference (weekday or any day) More...
 
bool IsTodayAChosenHuntDay (int a_today)
 Uses a probability test to determine whether to go hunting today. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Protected Attributes

Goose_Population_Managerm_preyPopulationManger
 Pointer to our game population, the geese. More...
 
polylistm_huntfields
 Our list of possible hunting fields as polygon reference numbers as supplied by Landscape::SupplyPolyRef(int,int);. More...
 
bool m_dugin
 Flag to show whether a hunting location has been found. More...
 
int m_goosebag [gst_foobar]
 A special bag data structure so the hunter knows what kind of geese he shot. More...
 
int m_pinkfootbaglimit
 Bag limit for pinkfoot. More...
 
int m_greylagbaglimit
 Bag limit for greylag. More...
 
bool m_leader
 When hunting this indicates whether the hunter is a team leader. More...
 
- Protected Attributes inherited from Hunter
int m_myname
 A reference number unique to this hunter. More...
 
TypeOfHunterState m_CurrentHState
 The current hunter behavioural state. More...
 
Hunter_Population_Managerm_OurPopulationManager
 Pointer to the population manager. More...
 
int m_clock
 Records the time spent hunting per day. More...
 
int m_bag
 The numbers of game items shot todate this year. More...
 
int m_myShots
 The numbers of shots to-date this year. More...
 
int m_myMagazine
 The number of shells in the magazine. More...
 
int m_huntingdays
 The numbers of days used for hunting this year. More...
 
int m_lasthuntday
 The date for the last hunt day. More...
 
int m_baglimit
 Annual self-imposed limit on number shot - unused at present. More...
 
int m_huntlimit
 Annual self-imposed limit on number of days spent hunting. More...
 
double m_efficiency
 Probability of 'hitting' a game item. More...
 
double m_goosecountchance
 Probability of checking for geese in hunting area. More...
 
int m_weekend
 Code for weekly hunting activity. More...
 
vector< Farm * > m_OurFarmers
 List of pointers to the farmers whose land the hunter hunts
More...
 
APoint m_Home
 
int m_huntfield_polyref
 The polygon reference number to our current hunting field (which is at a hunting location) More...
 
int m_NoHuntLocs
 
vector< int > m_HuntLocRefs
 
vector< APointm_HuntLocs
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Detailed Description

The class for goose hunters encompsassing all their specific behaviours.

Constructor & Destructor Documentation

◆ GooseHunter()

GooseHunter::GooseHunter ( struct_Hunter p_data,
Hunter_Population_Manager p_PPM 
)

GooseHunter constructor.

1197  : Hunter(p_data, p_PPM)
1198 {
1199  m_preyPopulationManger = dynamic_cast<Goose_Population_Manager*>(p_data->m_preyPM);
1200  m_OurFarmers = p_data->m_farms;
1201  m_leader = false;
1204  Init();
1205 }
static CfgInt cfg_hunter_pinkfootbaglimit("HUNTER_PINKFOOTBAGLIMIT", CFG_CUSTOM, 9999)
The pinkfoot hunting bag limit.
static CfgInt cfg_hunter_greylagbaglimit("HUNTER_GREYLAGBAGLIMIT", CFG_CUSTOM, 9999)
The greylag hunting bag limit.
int value(void)
Definition: configurator.h:98
The class to handle all goose population related matters.
Definition: Goose_Population_Manager.h:393
bool m_leader
When hunting this indicates whether the hunter is a team leader.
Definition: Hunters_all.h:285
int m_pinkfootbaglimit
Bag limit for pinkfoot.
Definition: Hunters_all.h:281
int m_greylagbaglimit
Bag limit for greylag.
Definition: Hunters_all.h:283
virtual void Init()
Initiation of a specific goose hunter here.
Definition: Hunters_all.cpp:1212
Goose_Population_Manager * m_preyPopulationManger
Pointer to our game population, the geese.
Definition: Hunters_all.h:273
vector< Farm * > m_OurFarmers
List of pointers to the farmers whose land the hunter hunts
Definition: Hunters_all.h:153
Hunter(struct_Hunter *p_data, Hunter_Population_Manager *p_PPM)
The constructor for the Hunter class.
Definition: Hunters_all.cpp:1075
Population_Manager * m_preyPM
Definition: Hunters_all.h:95
vector< Farm * > m_farms
Definition: Hunters_all.h:89

References cfg_hunter_greylagbaglimit, cfg_hunter_pinkfootbaglimit, Init(), struct_Hunter::m_farms, m_greylagbaglimit, m_leader, Hunter::m_OurFarmers, m_pinkfootbaglimit, struct_Hunter::m_preyPM, m_preyPopulationManger, and CfgInt::value().

◆ ~GooseHunter()

GooseHunter::~GooseHunter ( )
virtual

GooseHunter destructor.

1208 {
1209  if (m_huntfields != NULL) delete m_huntfields;
1210 }
polylist * m_huntfields
Our list of possible hunting fields as polygon reference numbers as supplied by Landscape::SupplyPoly...
Definition: Hunters_all.h:275

References m_huntfields.

Member Function Documentation

◆ CheckForGame()

int GooseHunter::CheckForGame ( void  )
protectedvirtual

If the hunter checks for game at their hunting locations then this is done here. Must be overridden.

Returns
int a polygon reference if we are to go hunting, or -1 = don't go hunting today

The hunter checks for legal game at their hunting fields if they are set to do so, otherwise they take a random shot at a place.
If they don't check then they automatically assume they can go out hunting.
Here we assume they check all their hunting locations and pick the best. We might also want as a later refinement to know how many geese because and only go out when there are a lot.

Reimplemented from Hunter.

1231  {
1240  int sz = int(m_huntfields->size());
1241  if (g_rand_uni() >= m_goosecountchance) {
1242  int thepolyref = (*m_huntfields)[int(g_rand_uni()*sz)]; // returns 0 to sz-1;
1243  return thepolyref;
1244  }
1245  else {
1246  // We are checking today, so check out hunting fields
1247  int polyref = -1;
1248  int maxgeese = 0;
1249  for (int hfield = 0; hfield < sz; hfield++) {
1250  int geese = m_OurLandscape->GetQuarryNumbers((*m_huntfields)[hfield]);
1251  if (geese > maxgeese) {
1252  maxgeese = geese;
1253  polyref = (*m_huntfields)[hfield];
1254  }
1255  }
1256  return polyref;
1257  }
1258 }
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
double m_goosecountchance
Probability of checking for geese in hunting area.
Definition: Hunters_all.h:149
int GetQuarryNumbers(int a_poly)
This returns the number of geese which are legal quarry on the polygon the day before.
Definition: Landscape.cpp:3390
Landscape * m_OurLandscape
Definition: PopulationManager.h:229

References g_rand_uni, Landscape::GetQuarryNumbers(), Hunter::m_goosecountchance, m_huntfields, and TAnimal::m_OurLandscape.

Referenced by st_OutHunting().

◆ FindHuntingLocation()

bool GooseHunter::FindHuntingLocation ( void  )
protected

Locate the hunt for today.

◆ GetSeasonLengthLeft()

int GooseHunter::GetSeasonLengthLeft ( int  day)
protectedvirtual

Returns the length of the hunting season in days - MUST be overridden in descendent class.

The goose hunting season is complicated because it runs over a year boundary (or it can)

Reimplemented from Hunter.

1296  {
1297  if (m_OurPopulationManager->GetSeasonNumber() == 0) return 0; // We don't want them to start in January in the first year of the sim.
1298  int left;
1302  if (start > end) {
1303  // We have a year boundary issue, if the day is in the autumn then we have til the end of year + next year, otherwise we must be in next year already.
1304  if (day >= start) left = (365 - day) + end;
1305  else left = end - day;
1306  }
1307  else {
1308  left = end - day;
1309  }
1310  // We don't want to return a negative number of days, so rather want to say no days left, i.e. 0
1311  if (left < 0) return 0;
1312  return left;
1313 }
int GetHuntingSeasonEnd()
Get the end of the overall hunting season.
Definition: Hunters_all.h:381
int GetHuntingSeasonStart()
Get the start of the overall hunting season.
Definition: Hunters_all.h:379
Hunter_Population_Manager * m_OurPopulationManager
Pointer to the population manager.
Definition: Hunters_all.h:129
int GetSeasonNumber()
Get the season number.
Definition: PopulationManager.h:578
@ start
Definition: treatment.h:32

References Hunter_Population_Manager::GetHuntingSeasonEnd(), Hunter_Population_Manager::GetHuntingSeasonStart(), Population_Manager::GetSeasonNumber(), Hunter::m_OurPopulationManager, and start.

◆ Init()

void GooseHunter::Init ( void  )
protectedvirtual

Initiation of a specific goose hunter here.

Here we need to create a list of possible goose hunting fields in our hunting locations. So we ask for openness scores for any fields with at each of our hunting locations. This is provided by Farm::ListOpenFields

1213 {
1219  m_huntfields = new polylist;
1220  for (int i = 0; i < m_NoHuntLocs; i++)
1221  {
1222  polylist* pl = m_OurFarmers[i]->ListOpenFields((int)cfg_goose_MinForageOpenness.value());
1223  m_huntfields->insert(m_huntfields->begin(), pl->begin(), pl->end()); // add the new one to the main polylist
1224  delete pl;
1225  }
1226  ResetClock();
1227  ResetSeasonData();
1228 }
CfgFloat cfg_goose_MinForageOpenness
double value(void)
Definition: configurator.h:118
void ResetSeasonData()
Sets the bag and hunting counters to zero.
Definition: Hunters_all.h:218
int m_NoHuntLocs
Definition: Hunters_all.h:159
void ResetClock()
Sets the clock back to zero.
Definition: Hunters_all.h:214
vector< unsigned > polylist
Definition: farm.h:207

References cfg_goose_MinForageOpenness, m_huntfields, Hunter::m_NoHuntLocs, Hunter::m_OurFarmers, Hunter::ResetClock(), Hunter::ResetSeasonData(), and CfgFloat::value().

Referenced by GooseHunter().

◆ InSeason()

bool GooseHunter::InSeason ( int  day)
protectedvirtual

Is it goose hunting season? - MUST be overridden in descendent class.

The goose hunting season is complicated because it runs over a year boundary (or it can) Particularly the first year of the simulation is tricky, because we start out in January which can be legal hunting season, but the geese don't arrive until the fall.

Reimplemented from Hunter.

1271  {
1279 
1280  return false; // We don't want them to start in January in the first year of the sim.
1281  }
1282  if (start > end) {
1283  if ((day < start) && (day > end)) return false;
1284  else {
1285  return true; // must be in the first year after the start of season
1286  }
1287  }
1288  else {
1289  // Season all in one year
1290  if (day < start || day > end) return false;
1291  else {
1292  return true;
1293  }
1294  }
1295 }

References Hunter_Population_Manager::GetHuntingSeasonEnd(), Hunter_Population_Manager::GetHuntingSeasonStart(), Population_Manager::GetSeasonNumber(), Hunter::m_OurPopulationManager, and start.

◆ IsLeader()

bool GooseHunter::IsLeader ( )
inline

Returns the leader flag.

325  {
326  return m_leader;
327  }

References m_leader.

Referenced by Hunter_Population_Manager::DoFirst().

◆ IsSeasonEnd()

bool GooseHunter::IsSeasonEnd ( int  day)
protectedvirtual

Is it the end of the goose hunting season? - MUST be overridden in descendent class.

Reimplemented from Hunter.

1260  {
1262  if (end == 365){
1263  m_OurLandscape->Warn("GooseHunter::IsSeasonEnd()", "Hunting season end at day 365. First day of the year is 0 hence last day of year is 364");
1264  exit(1);
1265  }
1266  if (day == 1 + end) return true;
1267  if (day == 0 && end == 364) return true; // if the hunting season ends at the end of the year, then day 0 is after it.
1268  return false;
1269 }
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579

References Hunter_Population_Manager::GetHuntingSeasonEnd(), TAnimal::m_OurLandscape, Hunter::m_OurPopulationManager, and Landscape::Warn().

◆ OnGoHome()

void GooseHunter::OnGoHome ( )
protectedvirtual

On gohome message handler.

Reimplemented from Hunter.

1438  {
1439  m_dugin = false; // End of the hunt, so no longer dugin
1440  m_leader = false; // Hunt is over, so nothing to lead.
1441  m_huntfield_polyref = -1; // This has to be reset. We find a new one next time we go hunting.
1442  m_CurrentHState = tohts_Resting; // Come home
1443 }
@ tohts_Resting
Definition: Hunters_all.h:60
bool m_dugin
Flag to show whether a hunting location has been found.
Definition: Hunters_all.h:277
TypeOfHunterState m_CurrentHState
The current hunter behavioural state.
Definition: Hunters_all.h:127
int m_huntfield_polyref
The polygon reference number to our current hunting field (which is at a hunting location)
Definition: Hunters_all.h:157

References Hunter::m_CurrentHState, m_dugin, Hunter::m_huntfield_polyref, m_leader, and tohts_Resting.

◆ OnShoot()

void GooseHunter::OnShoot ( )
protectedvirtual

On shoot message handler.

This is a message handler for the situation when a hunter is in a team but not the leader. When the leader decides to shoot the other team members hunter will shoot. When a bird is shot the message is sent to the goose population manager. This works out which birds are shot and removes them, calling back with an OnShotABird message so the hunter can record what has been shot. It is here that the bag record is kept.

Reimplemented from Hunter.

1419  {
1426  int numbershot = 0;
1427  m_myShots++;
1428  if (g_rand_uni() < m_efficiency) numbershot++;
1429  if (birds > 1){
1430  if (g_rand_uni() < m_efficiency) numbershot++;
1431  m_myShots++;
1432  }
1433  if (numbershot > 0) {
1435  }
1436 }
void BirdsShot(int a_polyref, int a_numbershot, GooseHunter *a_Hunter)
Passes the message to shoot a number of birds at a forage location.
Definition: Goose_Population_Manager.cpp:1862
int BirdsToShootAtPoly(int a_poly)
Returns the number of birds at a forage location - given by a poly ref.
Definition: Goose_Population_Manager.cpp:1833
double m_efficiency
Probability of 'hitting' a game item.
Definition: Hunters_all.h:147
int m_myShots
The numbers of shots to-date this year.
Definition: Hunters_all.h:135

References Goose_Population_Manager::BirdsShot(), Goose_Population_Manager::BirdsToShootAtPoly(), g_rand_uni, Hunter::m_efficiency, Hunter::m_huntfield_polyref, Hunter::m_myShots, and m_preyPopulationManger.

◆ OnShotABird()

void GooseHunter::OnShotABird ( int  a_birdtype,
int  a_poly 
)

Message received when a goose is successully shot.

1413  {
1414  m_bag++;
1415  m_goosebag[a_birdtype]++;
1417 }
static CfgBool cfg_Hunters_RecordBag("HUNTERS_RECORDBAG", CFG_CUSTOM, false)
Should we record the birds shot?
bool value(void)
Definition: configurator.h:135
int m_goosebag[gst_foobar]
A special bag data structure so the hunter knows what kind of geese he shot.
Definition: Hunters_all.h:279
void RecordHuntingSuccess(int poly, int birds, int a_hunter)
Hunting bag output.
Definition: Hunters_all.cpp:1002
int m_myname
A reference number unique to this hunter.
Definition: Hunters_all.h:125
int m_bag
The numbers of game items shot todate this year.
Definition: Hunters_all.h:133

References cfg_Hunters_RecordBag, Hunter::m_bag, m_goosebag, Hunter::m_myname, Hunter::m_OurPopulationManager, Hunter_Population_Manager::RecordHuntingSuccess(), and CfgBool::value().

Referenced by Goose_Population_Manager::BirdsShot().

◆ ResetBag()

virtual void GooseHunter::ResetBag ( )
inlinevirtual

Sets the annual hunting bag to zero.

Reimplemented from Hunter.

320  {
322  for (int i = 0; i < gst_foobar; i++) m_goosebag[ i ] = 0;
323  }
@ gst_foobar
Definition: Goose_Base.h:66
virtual void ResetBag()
Sets the annual hunting bag to zero.
Definition: Hunters_all.h:201

References gst_foobar, m_goosebag, and Hunter::ResetBag().

◆ SaveMyData()

void GooseHunter::SaveMyData ( ofstream *  a_ofile)
virtual

Each hunter needs to save different kinds of data, so we use a polymorphic method for this.

Reimplemented from Hunter.

1469  {
1470  (*a_ofile) << m_myname << '\t' << GetHuntingDays() << '\t' << GetBag() << '\t' << GetShots();
1471  for (int i = 0; i < gst_foobar; i++) {
1472  (*a_ofile) << '\t' << m_goosebag[ i ];
1473  }
1474  (*a_ofile) << endl;
1475 
1476 }
int GetShots()
Gets the number of shots this season to-date.
Definition: Hunters_all.h:197
int GetHuntingDays()
Gets the annual hunting attempts count.
Definition: Hunters_all.h:189
int GetBag()
Gets the annual hunting bag.
Definition: Hunters_all.h:193

References Hunter::GetBag(), Hunter::GetHuntingDays(), Hunter::GetShots(), gst_foobar, m_goosebag, and Hunter::m_myname.

◆ st_OutHunting()

TypeOfHunterState GooseHunter::st_OutHunting ( void  )
protected

The basic hunting behaviour.

First at last check if the hunter checks for geese before going, if there are none he does not go out. Simulates a 10 minute hunting timestep. Must determine the time spent hunting and the time of day. Then wait for geese, and determine the probability of shooting them. Once the hunting time is used up, then come home.

We have a place to hunt - so look and see if there is anything to shoot Must assess a range from our location - we will be centrally placed in a field - so the real location is not precise beyond this resolution. Birds will also be located at the field level, so a simplifying assumption here is that a bird in the same field is 'fair game', outside the field it is not. Once we determine that there is something to shoot at, then we need to determine whether, we try and shoot, if so whether we hit the bird. If we shoot this must be registered in the system as an event, and any goose near enough to be affected will need to be told of this.

m_huntloc_index holds the polyref, from which we can get access to the forage locations in the goose manager - this has a list of who is there at any one moment in time.

When assessing whether to shoot the mix of the birds present will be critical. If it is primarily Barnacles then these are protected so the hunter will not shoot if not he can go ahead. The current solution just ignores barnacle geese - they cannot be shot and are not counted in the number of geese on a field.

A further consideration is whether the geese land near to the hunter. If too far away then they will not shoot. This depends on the area of the field. We assume that any field of less than 2Ha, then the geese are close enough, but if over this then there is a cfg_largefieldgooseproximity chance of shooting.

To Determine if we try to shoot and the chance of hitting, right now we assume we always shoot and the chance of hitting something is our skill - held in m_efficiency. The hunter has as many shots as is in his magazine (determined by the member variable m_myMagazine)

When a bird is shot the message is sent to the goose population manager. This works out which birds are shot and removes them, calling back with an OnShotABird message so the hunter can record what has been shot. It is here that the bag record is kept.

1333 {
1341  m_clock += 10; // this is not strictly necessary, but makes useful debug info (only leader cares)
1342  if (!m_dugin) {
1344  if (m_huntfield_polyref == -1) return tohts_Resting;
1345  else {
1346  m_huntingdays++;
1347  m_dugin = true;
1350  return tohts_OutHunting;
1351  }
1352  }
1353  if (m_leader) {
1354  // Only the leader assesses this
1355  if (m_clock > cfg_huntlength.value())
1356  {
1357  m_dugin = false;
1359  m_huntfield_polyref = -1;
1360  return tohts_Resting; // Come home
1361  }
1377  double fieldsize = m_OurLandscape->SupplyPolygonArea( m_huntfield_polyref );
1378  double shootingchance = 1.0;
1379  if (fieldsize > cfg_largefieldgooseproximitysizecutoff.value()) {
1380  shootingchance = cfg_largefieldgooseproximity.value();
1381  }
1382  /*double pct = 0.0;*/
1384 
1385  if ((birds > 0) && (g_rand_uni() < shootingchance) /* && (pct<cfg_huntermaxprotectedpct.value())*/ ) {
1393  int numbershot = 0;
1394  for (int i = 0; i < m_myMagazine; ++i) {
1395  if ((birds > i) || (numbershot == 0))
1396  {
1397  if (g_rand_uni() < m_efficiency) numbershot++;
1398  m_myShots++;
1399  }
1400  }
1401  if (numbershot > 0) {
1403  }
1405  // All shots are fired then make some sound
1406  // Must scare any birds off that are near here and get them to remember the event
1408  }
1409  }
1410  return tohts_OutHunting;
1411 }
static CfgFloat cfg_largefieldgooseproximity("HUNTER_LARGEFIELDGOOSEPROXIMITYCHANCE", CFG_CUSTOM, 0.5)
The likelihood that geese are close enough to shoot on large fields
static CfgInt cfg_huntlength("GOOSE_HUNTER_HUNT_LENGTH", CFG_CUSTOM, 180)
The default length of hunting.
static CfgInt cfg_largefieldgooseproximitysizecutoff("HUNTER_LARGEFIELDGOOSEPROXIMITYCHANCESIZECUTOFF", CFG_CUSTOM, 20000)
The size of the field which will trigger the use of cfg_largefieldgooseproximity.
@ tohts_OutHunting
Definition: Hunters_all.h:59
@ hlm_gohome
Definition: Hunters_all.h:71
@ hlm_shoot
Definition: Hunters_all.h:70
void BangAtPoly(int a_polyref)
Passes a 'Bang' message to birds near to the location specified by the polygon reference.
Definition: Goose_Population_Manager.cpp:1947
virtual int CheckForGame(void)
If the hunter checks for game at their hunting locations then this is done here. Must be overridden.
Definition: Hunters_all.cpp:1231
bool AddHunterHunting(int a_polyref, Hunter *a_hunter)
Adds a hunter hunting, returns true if that hunter is the leader otherwise false.
Definition: Hunters_all.cpp:1478
void HunterLeaderMessage(TypeOfHunterLeaderMessage a_signal, int a_polyref)
A message system to rely messages from the leader hunter to others in his team.
Definition: Hunters_all.cpp:1027
int m_lasthuntday
The date for the last hunt day.
Definition: Hunters_all.h:141
int m_myMagazine
The number of shells in the magazine.
Definition: Hunters_all.h:137
int m_huntingdays
The numbers of days used for hunting this year.
Definition: Hunters_all.h:139
int m_clock
Records the time spent hunting per day.
Definition: Hunters_all.h:131
long SupplyGlobalDate(void)
Definition: landscape.h:1621
double SupplyPolygonArea(int a_polyref)
Definition: landscape.h:523

References Hunter_Population_Manager::AddHunterHunting(), Goose_Population_Manager::BangAtPoly(), Goose_Population_Manager::BirdsShot(), Goose_Population_Manager::BirdsToShootAtPoly(), cfg_huntlength, cfg_largefieldgooseproximity, cfg_largefieldgooseproximitysizecutoff, CheckForGame(), g_rand_uni, hlm_gohome, hlm_shoot, Hunter_Population_Manager::HunterLeaderMessage(), Hunter::m_clock, m_dugin, Hunter::m_efficiency, Hunter::m_huntfield_polyref, Hunter::m_huntingdays, Hunter::m_lasthuntday, m_leader, Hunter::m_myMagazine, Hunter::m_myShots, TAnimal::m_OurLandscape, Hunter::m_OurPopulationManager, m_preyPopulationManger, Landscape::SupplyGlobalDate(), Landscape::SupplyPolygonArea(), tohts_OutHunting, tohts_Resting, CfgInt::value(), and CfgFloat::value().

Referenced by Step().

◆ st_ShouldGoHunting()

TypeOfHunterState GooseHunter::st_ShouldGoHunting ( void  )
protectedvirtual

Behavior involved in deciding whether to go hunting.

Here we check for any goose specific bag limits

Otherwise we want to find out if we should hunt today - this depends on the season for our game species, and whether we want to hunt today - which depends on whether it is a weekend or not - and then how eager we are.

Reimplemented from Hunter.

1316 {
1324  else
1325  {
1326  return(Hunter::st_ShouldGoHunting());
1327  }
1328 
1329 }
@ gst_PinkfootFamilyGroup
Definition: Goose_Base.h:60
@ gst_PinkfootNonBreeder
Definition: Goose_Base.h:61
virtual TypeOfHunterState st_ShouldGoHunting(void)
Decide whether to go out hunting on a specific day.
Definition: Hunters_all.cpp:1109

References gst_PinkfootFamilyGroup, gst_PinkfootNonBreeder, m_goosebag, m_pinkfootbaglimit, Hunter::st_ShouldGoHunting(), and tohts_Resting.

Referenced by Step().

◆ Step()

void GooseHunter::Step ( void  )
virtual

GooseHunter Step code.

Reimplemented from TAnimal.

1447 {
1448  if (m_StepDone || m_CurrentStateNo == -1) return;
1449  switch (m_CurrentHState)
1450  {
1451  case tohts_InitialState: // Initial state always starts by setting the behaviour to tohts_Hunting
1453  break;
1454  case tohts_Hunting:
1456  break;
1457  case tohts_OutHunting:
1459  break;
1460  case tohts_Resting:
1462  break;
1463  default:
1464  m_OurLandscape->Warn("GooseHunter::Step()","unknown state - default");
1465  exit(1);
1466  }
1467 }
@ tohts_Hunting
Definition: Hunters_all.h:58
@ tohts_InitialState
Definition: Hunters_all.h:57
virtual TypeOfHunterState st_ShouldGoHunting(void)
Behavior involved in deciding whether to go hunting.
Definition: Hunters_all.cpp:1315
TypeOfHunterState st_OutHunting(void)
The basic hunting behaviour.
Definition: Hunters_all.cpp:1332
TypeOfHunterState st_Resting(void)
Finished hunting and waiting for the next opportunity.
Definition: Hunters_all.cpp:1185
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:118
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:116

References Hunter::m_CurrentHState, TALMaSSObject::m_CurrentStateNo, TAnimal::m_OurLandscape, TALMaSSObject::m_StepDone, st_OutHunting(), Hunter::st_Resting(), st_ShouldGoHunting(), tohts_Hunting, tohts_InitialState, tohts_OutHunting, tohts_Resting, and Landscape::Warn().

Member Data Documentation

◆ m_dugin

bool GooseHunter::m_dugin
protected

Flag to show whether a hunting location has been found.

Referenced by OnGoHome(), and st_OutHunting().

◆ m_goosebag

int GooseHunter::m_goosebag[gst_foobar]
protected

A special bag data structure so the hunter knows what kind of geese he shot.

Referenced by OnShotABird(), ResetBag(), SaveMyData(), and st_ShouldGoHunting().

◆ m_greylagbaglimit

int GooseHunter::m_greylagbaglimit
protected

Bag limit for greylag.

Referenced by GooseHunter().

◆ m_huntfields

polylist* GooseHunter::m_huntfields
protected

Our list of possible hunting fields as polygon reference numbers as supplied by Landscape::SupplyPolyRef(int,int);.

Referenced by CheckForGame(), Init(), and ~GooseHunter().

◆ m_leader

bool GooseHunter::m_leader
protected

When hunting this indicates whether the hunter is a team leader.

Referenced by GooseHunter(), IsLeader(), OnGoHome(), and st_OutHunting().

◆ m_pinkfootbaglimit

int GooseHunter::m_pinkfootbaglimit
protected

Bag limit for pinkfoot.

Referenced by GooseHunter(), and st_ShouldGoHunting().

◆ m_preyPopulationManger

Goose_Population_Manager* GooseHunter::m_preyPopulationManger
protected

Pointer to our game population, the geese.

Referenced by GooseHunter(), OnShoot(), and st_OutHunting().


The documentation for this class was generated from the following files: